package com.example.redis.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * description
 * </p>
 *
 * @author luanmingbin@byteplan.com
 *        @since 2024/8/26 10:14
 */
@RestController
@RequestMapping("/api/redis")
public class RedisSendMsgController {
    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @PostMapping(value = "/send" , produces = MediaType.APPLICATION_JSON_VALUE)
    public String sendMsg(@RequestParam String msg) {
        redisTemplate.convertAndSend("service1", msg);
        return "success";
    }
}
